<template>
  <!-- Vue3组件中的模板结构没有根标签 -->
  <h1>一个人的信息</h1>
  <h2>姓名：{{person.name}}</h2>
  <h2>年龄:{{person.age}}</h2>
  <h3>职位:{{person.job.type}}</h3>
  <h3>工资:{{person.job.salary}}</h3>
  <h3>爱好:{{person.hobby}}</h3>
  <h3>测试的数据:{{person.job.a.b.c}}</h3>
  <button @click="changeInfo">修改人的信息</button>
</template>

<script>
  // import {h} from 'vue'
  import { reactive } from 'vue'
  export default {
    name: 'App',
    setup() {
      let person = reactive({//简称Proxy对象，基于ES6的Proxy实现，通过代理对象操作源对象的内部数据进行操作
        name:'张三',
        age:18,
        job:{
          type:'前端',
          salary:'7K',
          a:{
            b:{
              c:666
            }
          }
        },
        hobby:['抽烟','喝酒','烫头']
      })
      function changeInfo(){
        person.name = '李四',
        person.age = '48'
        person.job.type = '后端',
        person.job.salary = '8.5K'
        person.job.a.b.c = '999'
        person.hobby[0] = '学习'
        console.log(person.hobby);
      }
       //返回一个对象(常用)
      return {
        person,
        changeInfo
      }
    }
  }
</script>

<style>
  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
  }
</style>
